<%
   request.headers['REQUEST_URI'] = "" if request.headers['REQUEST_URI'].nil?
   realUrl = request.original_url
   if   (realUrl.match(/forge\.trustie\.net\/*/))
     @nav_dispaly_project_label = 1
     @nav_dispaly_forum_label = 1
   elsif (realUrl.match(/course\.trustie\.net\/*/))
     @nav_dispaly_course_all_label = 1
     @nav_dispaly_forum_label = 1
     @nav_dispaly_course_label = nil
     @nav_dispaly_store_all_label = 1
   elsif (realUrl.match(/user\.trustie\.net\/*/))
     @nav_dispaly_home_path_label = 1
     @nav_dispaly_main_course_label = 1
     @nav_dispaly_main_project_label = 1
     @nav_dispaly_main_contest_label = 1
   elsif (realUrl.match(/contest\.trustie\.net\/*/))
     @nav_dispaly_contest_label = 1
     @nav_dispaly_store_all_label = 1
   elsif (realUrl.match(/ossean\.trustie\.net\/*/))
     @nav_dispaly_osp_index_label = 1
     @nav_dispaly_project_label = nil
     @nav_dispaly_project_all_label = nil
     @nav_dispaly_course_all_label = nil
     @nav_dispaly_forum_label = nil
     @nav_dispaly_bid_label = nil
     @nav_dispaly_contest_label = nil
     @nav_dispaly_store_all_label = nil
     @nav_dispaly_user_label = nil
   elsif (realUrl.match(/localhost:3000\/*/))
     @nav_dispaly_osp_index_label = 1
     @nav_dispaly_project_label = nil
     @nav_dispaly_project_all_label = nil
     @nav_dispaly_course_all_label = nil
     @nav_dispaly_forum_label = nil
     @nav_dispaly_bid_label = nil
     @nav_dispaly_contest_label = nil
     @nav_dispaly_store_all_label = nil
     @nav_dispaly_user_label = nil
   else
   	 @nav_dispaly_osp_index_label = 1
     # @nav_dispaly_project_all_label = 1
     # @nav_dispaly_course_all_label = 1
     # @nav_dispaly_forum_label = 1
     # @nav_dispaly_bid_label = 1
     # @nav_dispaly_contest_label = 1
     # @nav_dispaly_store_all_label = 1
     # @nav_dispaly_user_label = 1
   end
%>
<div id="top-menu" style="border-radius: 0px; width: 100%; background-color: #269AC9;height:340px;margin-top: 10px;margin-bottom: 10px;">
  <div style="width: 940px; margin: auto;">
    <div>
      <div class="welcome_logo">
        <!-- <%= link_to image_tag("/images/logo.png", weight: "36px", height: "36px"), home_path %> -->
      </div>
      <%#= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%>
      <%#= render_dynamic_nav if User.current.logged? || !Setting.login_required? -%>
      <%# 自建导航条在base页面中以 (@nav_dispaly......) 开头变量设定， 全局搜索即可发现 %>
    </div>
    <div style="clear: both;"></div>

    <div style="float: left; margin-left: 15%; width: 70%; margin-top: 100px; margin-bottom: 100px;">
      <h1 style="text-align: center;">
        <span style="font-size: 36px;">OSSEAN:</span><br>
        <span class="color-grey" style="font-size: 20px; text-transform: uppercase">
        OSS
        <!--<span style="color: #E9770D;">Evaluating</span>,-->
        <!--<span style="color: #0d8ecf;">Analyzing </span>&amp;-->
        <!--<span style="color: #15bccf;">Networking</span>-->
        <span>Evaluating</span>,
        <span>Analyzing </span>&amp;
        <span>Networking</span>
        </span>
      </h1>

      <%= form_tag({controller: :open_source_projects, action: :search}, method: :get, :target => :_blank, :style=> 'float: left; margin-left: 85px; width: 500px; background: #FFFFFF') do %>
              <%= text_field_tag :name, nil, placeholder: '输入关键词进行搜索',
                                 :style => "float: left; width: 450px; padding-left: 10px; height: 27px; border: none;", :class => "projects-search-text-field",
                                 :onChange => "$('.topics-search-text-field').val($('.projects-search-text-field').val())" %>
              <%= submit_tag '', :style => " float: left; width: 35px; border: none;", :id => "search_bar", :name => nil, :onclick => "user_trace_search_project_in_welcome('#{request.session_options[:id]}');" %>
            <style type="text/css">
                #search_bar {width:30px; height:32px; background:url(../images/nav_icon.png) -8px 3px no-repeat; float:left;}
                input#search_bar:hover {background:url(../images/nav_icon.png) -49px 3px no-repeat;}
            </style>
      <% end %>
    </div>

  </div>


</div>
<div style="border-top:solid 1px #C6E9F1;width:940px;margin-left:auto;margin-right:auto;margin-bottom: 0px;margin-top: -10px;"></div>
<div style="clear:left;"></div>

<!-- ajax user trace zhangxunhui begin -->
<script type="text/javascript">
	function user_trace_search_project_in_welcome(session_id){
    	content = $('.projects-search-text-field').val(); //获取搜索的内容
    	if (content == "" || content == null){
    		return;
    	}else{
    		content = encodeURIComponent(content);
	    	$.ajax({
				contentType: "application/json; charset=utf-8",
				timeout: 5000,
				url: '/user_traces/search_project?keyword=' + content + "&session_id=" + session_id,
				dataType: "json"
			});
    	}
    }
</script>
<!-- ajax user trace zhangxunhui end -->

<script type="text/javascript">
    function addSlipMenu() {
        var loggedas = $('#loggedas ul li:first')
        var sub_menu = $('.sub_menu')
        loggedas.mouseenter(function (event) {
            sub_menu.show();
        });
        sub_menu.mouseleave(function (event) {
            sub_menu.hide();
        });
    }

    $(document).ready(function () {
        addSlipMenu();
    });

    jQuery(document).ready(function ($) {
        $('.sub_menu').find("a").attr('target', '_blank');
    });
    
</script>